<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>绑定教务系统帐号</title>
    <link rel="stylesheet" href="__PUBLIC__/Main/css/weui.min.css"/>
    <link rel="stylesheet" href="__PUBLIC__/Main/css/example.css"/>
</head>
<body>
<div class="hd">
    <h1 class="page_title">绑定教务</h1>
    <p class="page_desc">广西水利电力职业技术学院</p>
</div>
<!--<div class="weui_cells_title">绑定教务系统帐号</div>-->
<form action="{:addons_url('Bdjw://Bdjw/login')}" method="post" id="form" onsubmit="return subcheck();">
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">学号</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" name="xh" type="text" placeholder="请输入学号" required/>
            </div>
        </div>
    </div>
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">密码</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" name="password" type="password" placeholder="请输入密码" required/>
            </div>
        </div>
    </div>
    <div class="weui_cells weui_cells_form" id="vk">
        <div class="weui_cell weui_vcode" id="verify">
            <div class="weui_cell_hd"><label class="weui_label">验证码</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" id="ver" name="verify" type="text" placeholder="请输入验证码" required/>
            </div>
            <div class="weui_cell_ft" id="img">
                <img src="{:addons_url('Bdjw://Bdjw/verify')}" onclick="this.src=this.src"/>
            </div>
        </div>
    </div>
    <div class="weui_btn_area">
        <input class="weui_btn weui_btn_primary" id="sub" type="submit" value="确定">
    </div>
</form>
<div id="loadingToast" class="weui_loading_toast" style="display:none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <div class="weui_loading">
            <div class="weui_loading_leaf weui_loading_leaf_0"></div>
            <div class="weui_loading_leaf weui_loading_leaf_1"></div>
            <div class="weui_loading_leaf weui_loading_leaf_2"></div>
            <div class="weui_loading_leaf weui_loading_leaf_3"></div>
            <div class="weui_loading_leaf weui_loading_leaf_4"></div>
            <div class="weui_loading_leaf weui_loading_leaf_5"></div>
            <div class="weui_loading_leaf weui_loading_leaf_6"></div>
            <div class="weui_loading_leaf weui_loading_leaf_7"></div>
            <div class="weui_loading_leaf weui_loading_leaf_8"></div>
            <div class="weui_loading_leaf weui_loading_leaf_9"></div>
            <div class="weui_loading_leaf weui_loading_leaf_10"></div>
            <div class="weui_loading_leaf weui_loading_leaf_11"></div>
        </div>
        <p class="weui_toast_content">绑定中</p>
    </div>
</div>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
<script>

    function check() {
        var ret;
        var verify = $("#ver").val();
        var url = "{:addons_url('Bdjw://Bdjw/check_verify')}";
        $.post(url, {verify: verify}, function (data) {
            if (data) {
                $("#verify").removeClass("weui_cell_warn");
                $("#img_warn").remove();
                $("#errmsg").remove();
                $("#sub").removeClass("weui_btn_disabled").addClass("weui_btn_primary");
                return ret = true;
            } else {
                $("#verify").removeClass("weui_cell_warn").addClass("weui_cell_warn");
                $("#img_warn").remove();
                $("#errmsg").remove();
                $("#sub").removeClass("weui_btn_primary").addClass("weui_btn_disabled");

                $("#img").prepend('<i id="img_warn" class="weui_icon_warn"></i>');
                $("#vk").after('<div class="weui_cells_tips" id="errmsg" style="color: red">如果看不清，可以点击图片更换</div>');
                return ret = false;
            }
        });
        return ret;
    }

    function subcheck() {
        $.ajaxSetup({
            async: false
        });
        if (check()) {
            $("#loadingToast").show();
            return true;
        } else {
            return false;
        }
    }
    $(function () {
        $("#ver").focusout(function () {
            check();
        });
    });
</script>
</body>
</html>